package com.qf.scheduler;

import com.qf.job.MyJob;
import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

public class MyCronScheduler {
    public static void main(String[] args) throws SchedulerException {
//        1 创建调度器
        Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();

//        2 编写触发器
        CronTrigger cronTrigger = TriggerBuilder.newTrigger().withIdentity("mycron", "mygrop")
                .withSchedule(CronScheduleBuilder.cronSchedule("0/2 * 16-17 * * ?"))//调度器规则
                .build();
//        3编写jobDetail
        JobDetail jobDetail = JobBuilder.newJob(MyJob.class).withIdentity("myDetail", "group").build();
//        4将触发器和任务添加到 调度器
        scheduler.scheduleJob(jobDetail, cronTrigger);

//        5 启动
        scheduler.start();
    }
}
